﻿//AcademicPlanner - course registration planning web app.
//Copyright (C) 2009  Boubacar Diallo

//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either version 2
//of the License, or (at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program; if not, write to the Free Software
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AcademicPlanner.Domain.Models;

namespace AcademicPlanner.Presentation.Views.Shared
{
	/// <summary>
	/// ProgramsControlModel represents a model
	/// object for a <c>ProgramsControl</c> control.
	/// </summary>
	/// <since>1.0</since>
	public class ProgramsControlModel : ControlModel
	{
		/// <summary>
		/// Gets or sets the <c>Program</c>s whose information
		/// is to be displayed.
		/// </summary>
		/// <since>1.0</since>
		public IList<Program> Programs { get; set; }
	}


	/// <summary>
	/// ProgramsControl represents a control for displaying
	/// information about <c>Program</c>s.
	/// </summary>
	/// <since>1.0</since>
	public partial class ProgramsControl : Control<ProgramsControlModel>
	{
		/// <summary>
		/// Gets or sets the list of actions in the context menu
		/// of a program in a list of programs.
		/// </summary>
		/// <since>1.0</since>
		protected IList<string> ContextMenuActions { get; set; }

		/// <summary>
		/// Gets or sets the list of icons to be displayed in the context menu
		/// of a program in a list of programs.
		/// </summary>
		/// <since>1.0</since>
		protected IList<string> ContextMenuIcons { get; set; }

		/// <summary>
		/// Handles the page load event for this control by initializing its
		/// properties.
		/// </summary>
		/// <param name="sender">The sender of the event.</param>
		/// <param name="e">The details of the event.</param>
		/// <since>1.0</since>
		protected void Page_Load(object sender, EventArgs e)
		{
			if (string.IsNullOrEmpty(Model.Id))
				Model.Id = "programsControl";

			ContextMenuActions = new List<string>();
			ContextMenuIcons = new List<string>();
			ContextMenuActions.Add(Html.Encode(Tr("Edit")));
			ContextMenuActions.Add(Html.Encode(Tr("Delete")));
			ContextMenuIcons.Add("edit.png");
			ContextMenuIcons.Add("trash_add.gif");
		}
	}
}